// 元素相对于body的offsetTop
export function getTop(el: HTMLElement) {
  let offsetTop = 0
  const pos = el.getBoundingClientRect()
  offsetTop = pos.top + document.documentElement.scrollTop
  /*
    while (el && el.tagName !== 'BODY') {
      offsetTop += el.offsetTop
      el = el.offsetParent
    }
    */
  return offsetTop
}
export function getLeft(el: HTMLElement) {
  let offsetLeft = 0
  const pos = el.getBoundingClientRect()
  offsetLeft = pos.left + document.documentElement.scrollLeft
  /*
    while (el && el.tagName !== 'BODY') {
      offsetLeft += el.offsetLeft
      el = el.offsetParent
    }
    */
  return offsetLeft
}
